#include <stdlib.h>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/lexical_cast.hpp>

#include "help_api.h"
#include "fake_int.h"
#include "memory_map_file.h"

using namespace boost;
using namespace property_tree;

using namespace std;

MemoryMappedFile* dma_file;

uint sectorSize;
uint dmaAddress;

void* init_dma(){
    ptree pt;
    ini_parser::read_ini("config.ini", pt);
    string sectorSizeStr = pt.get<string>("Config.SectorSize");
    sectorSize = strtol(sectorSizeStr.c_str(),0,0);
    string dmaAddressStr = pt.get<string>("Config.DmaAddress");
    dmaAddress = strtol(dmaAddressStr.c_str(),0,0);
    dma_file = new MemoryMappedFile(sectorSize, dmaAddress);
    return (void*)dmaAddress;
}

void clean_dma(){
    delete dma_file;
}
